import { defineStore } from "pinia";

export default defineStore('main',{
    state:()=>{
        return {
            count:10,
            list:[
                {
                    name:"iphone14 pro max ",
                    price: 8999
                },
                {
                    name:"iphone13 pro",
                    price:6450
                },
                {
                    name:"xiao mi 12utral",
                    price:3999
                }
            ]
        }
    } ,
    getters:{
        sumPrice:(state)=>{
            let sumPrice ;
            state.list.forEach((item)=>{
                sumPrice+=item.price
            })
            return sumPrice ;
        }
    },
    // 同步和异步都可以
    actions:{
        
    }
})